package com.geely.common;

import com.geely.controller.AdmHomeController;
import com.geely.controller.AdmUserController;
import com.geely.controller.BreakDownController;
import com.geely.controller.ComLoginController;
import com.geely.controller.CommonController;
import com.geely.controller.RecordController;
import com.geely.controller.ShiftChangeController;
import com.geely.controller.UserHomeController;
import com.geely.model.Adm;
import com.geely.model.BreakDown;
import com.geely.model.Record;
import com.geely.model.ShiftChange;
import com.geely.model.SpareParts;
import com.geely.model.Station;
import com.geely.model.User;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.template.Engine;

public class MainConfig extends JFinalConfig 
{

	@Override
	public void configConstant(Constants me) 
	{
		loadPropertyFile("a_little_config.txt");
		me.setDevMode(true);

	}

	@Override
	public void configRoute(Routes me) 
	{
		me.add("/", CommonController.class);
		me.add("/comlogin",ComLoginController.class);
		me.add("/userhome", UserHomeController.class);
		me.add("/admHome", AdmHomeController.class);
		me.add("/record",RecordController.class);
		me.add("/shiftChange",ShiftChangeController.class);
		me.add("admUser",AdmUserController.class);

	}

	@Override
	public void configEngine(Engine me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configPlugin(Plugins me) {
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password").trim());
		me.add(c3p0Plugin);
		
		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.setShowSql(true);
		arp.addMapping("user", User.class);
		arp.addMapping("adm", Adm.class);
		arp.addMapping("record", Record.class);
		arp.addMapping("shiftChange", ShiftChange.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		JFinal.start("WebRoot", 80, "/", 5);
	}
}
